<template>
  <div>
    <div v-if="!edit">
      {{ value.cval }}
    </div>
    <Field type="number"
           v-if="edit"
           :key="field.name"
           v-model="newval"
           :title="field.title"
           button-style="round"
           value-text-align="left"
           :required="field.required || false"
           @input="onchange"
    />
  </div>
</template>

<script>
  import {Field} from "vant"

  export default {
    name: 'FieldInteger', components: {Field},
    props: {
      field: {
        type: Object, default() {
          return {}
        }
      },

    edit: { type: Boolean, defautl: false }
  }, inject: ['value'],
  data: function () {
    return {newval: this.value.cval || 0}
  },
  computed: {
  },
  methods: {
    onchange: function (val) {
      this.value.newval = parseInt(this.newval)
      this.$emit('input', this.value)
    }
  }
}
</script>

<style scoped>

</style>
